<%= form_for [:admin, @shop], html: { class: "card" } do |f| %>
  <div class="card-body">
    <h3 class="card-title">
      <% if @shop.new_record? %>
      添加商家
      <% else %>
      修改商家
      <% end %>
    </h3>
    <div class="row">
      <%= render 'admin/shared/error_messages', target: @shop %>
    </div>
    <div class="row">
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">名字</label>
          <%= f.text_field :name, class: "form-control" %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">电话</label>
          <%= f.text_field :phone, class: "form-control" %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">店铺LOGO</label>
          <div class="custom-file">
            <%= f.file_field :avatar, class: "custom-file-input" %>
            <label class="custom-file-label">选择文件</label>
          </div>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">店铺大尺寸LOGO<small>750x430</small></label>
          <div class="custom-file">
            <%= f.file_field :big_avatar, class: "custom-file-input" %>
            <label class="custom-file-label">选择文件</label>
          </div>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">门店类型</label>
          <%= f.select :shop_type_id, ShopType.select('id, name').map{ |shop_type| [shop_type.name, shop_type.id] }, { include_blank: '请选择类型' }, { class: 'form-control select' } %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">收款银行（具体到支行）</label>
          <%= f.text_field :bank, class: "form-control" %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">银行账号</label>
          <%= f.text_field :bank_account, class: "form-control" %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">收款人名字</label>
          <%= f.text_field :bank_account_name, class: "form-control" %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">提成比列<small>（0-100）</small></label>
          <%= f.number_field :sales_percent, class: "form-control", min: '0', max: '100' %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <div class="form-label">是否自营</div>
          <div class="custom-controls-stacked">
            <label class="custom-control custom-checkbox">
              <%= f.check_box :direct_sale, class: "custom-control-input" %>
              <span class="custom-control-label">勾选是自营</span>
            </label>
          </div>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <div class="form-label">店铺经营范围</div>
          <div class="custom-controls-stacked">
            <label class="custom-control custom-radio custom-control-inline">
              <%= f.radio_button :business_range, "province", { class: "custom-control-input" } %>
              <span class="custom-control-label">省</span>
            </label>
            <label class="custom-control custom-radio custom-control-inline">
              <%= f.radio_button :business_range, "city", { class: "custom-control-input" } %>
              <span class="custom-control-label">市</span>
            </label>
            <label class="custom-control custom-radio custom-control-inline">
              <%= f.radio_button :business_range, "district", { class: "custom-control-input" } %>
              <span class="custom-control-label">县区</span>
            </label>
          </div>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <div class="form-label">店铺状态</div>
          <div class="custom-controls-stacked">
            <label class="custom-control custom-radio custom-control-inline">
              <%= f.radio_button :state, "opening", { class: "custom-control-input" } %>
              <span class="custom-control-label">营业</span>
            </label>
            <label class="custom-control custom-radio custom-control-inline">
              <%= f.radio_button :state, "stop", { class: "custom-control-input" } %>
              <span class="custom-control-label">停业</span>
            </label>
          </div>
        </div>
      </div>
    </div>
    
    <div class="row cities-select">
      <div class="col-sm-6 col-md-4">
        <div class="form-group">
          <label class="form-label">省份</label>
          <%= f.select :province_id, Province.select('id, name').map{ |city| [city.name, city.id] }, { include_blank: '请选择省份' }, { class: 'china-region-select form-control', "data-region-name" => "province_id", "data-sub-region" => "city_id" } %>
        </div>
      </div>
      <div class="col-sm-6 col-md-4">
        <div class="form-group">
          <label class="form-label">城市</label>
          <%= f.select :city_id, City.where(province_id: f.object.province_id).select('id, name').map{ |city| [city.name, city.id] }, { include_blank: '请选择城市' }, { class: 'china-region-select form-control', "data-region-name" => "city_id", "data-sub-region" => "district_id" } %>
        </div>
      </div>
      <div class="col-sm-6 col-md-4">
        <div class="form-group">
          <label class="form-label">县区</label>
          <%= f.select :district_id, District.where(city_id: f.object.city_id).select('id, name').map{ |city| [city.name, city.id] }, { include_blank: '请选择县区' }, { class: 'china-region-select form-control', "data-region-name" => "district_id" } %>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-md-12">
        <div class="form-group">
          <label class="form-label">详细地址</label>
          <%= f.text_field :address, class: "form-control" %>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">法人身份证正面</label>
          <div class="custom-file">
            <%= f.file_field :idcard_front, class: "custom-file-input" %>
            <label class="custom-file-label">选择文件</label>
          </div>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">法人身份证反面</label>
          <div class="custom-file">
            <%= f.file_field :idcard_back, class: "custom-file-input" %>
            <label class="custom-file-label">选择文件</label>
          </div>
        </div>
      </div>
      <div class="col-md-4">
        <div class="form-group">
          <label class="form-label">工商营业执照</label>
          <div class="custom-file">
            <%= f.file_field :license, class: "custom-file-input" %>
            <label class="custom-file-label">选择文件</label>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="card-footer text-right">
    <button type="submit" class="btn btn-primary">保 存</button>
  </div>
<% end %>